package com.yjd.pub.resource.service;

import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.comm.resource.model.OrderPicsModel;
import com.yjd.comm.resource.model.ResourceModel;
import com.yjd.comm.resource.service.IResourceService;
import com.yjd.pub.resource.dao.IResourceDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <b>description</b>：图片资源业务实现<br>
 * <b>time</b>：2017-06-27 08:57:02 <br>
 * <b>author</b>：  yangchangyan@yijiedai.com
 */
@Service("resourceService")
public class ResourceServiceImpl extends BaseServiceImpl implements IResourceService {

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public ResourceModel insert(ResourceModel model) throws Exception {
		return this.resourceDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(ResourceModel model) throws Exception {
		return this.resourceDao.updateModel(model, true);
	}

	/**
	 * 根据id删除
	 * 
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public int delete(long id) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("id", id);
		return this.resourceDao.deleteModel(paramMap, true);
	}

	/**
	 * 查询订单下所有的项目的图片
	 *
	 * @param param
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<OrderPicsModel> getPicsListByOrdeId(Map<String,Object> param) throws Exception {
		return this.resourceDao.getPicsListByOrdeId(param);
	}

	@Resource
	private IResourceDao resourceDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.resourceDao;
	}

}
